home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 1997 July / Freeware CD.iso / FREEWARE / !utils / sfs / SFS117!.EXE / SFS8.DOC < prev    next >
Encoding:
Text File  |  1995-03-20  |  59.3 KB  |  1,260 lines

  1. SFS Disk Volume Layout
  2. ----------------------
  3.  
  4. An SFS volume is broken up into two parts, the boot sector which is used to
  5. identify the volume and store assorted status information, and the encrypted
  6. volume itself.  If a program tries to read the boot sector, the SFS driver will
  7. assemble a pseudo-boot sector in memory and return that instead.  If a program
  8. tries to write to the boot sector, the SFS driver will skip the boot sector
  9. while still writing any other sectors which may be requested.
  10.  
  11. All data on the boot sector, both plaintext and encrypted, is stored in
  12. big-endian format following the convention used by international cryptographic
  13. standards.  Care should to taken to ensure that the proper endianness is
  14. maintained when reading and writing the boot sector on little-endian systems
  15. (the performance of the current implementation was tested against the RS6000
  16. version to confirm that endianness conversion was being done correctly).
  17.  
  18. In the following discussion a BYTE is an 8-bit quantity, a WORD is a big-
  19. endian 16-bit quantity, and a LONG is a big-endian 32-bit quantity.  There are
  20. no alignment restrictions for the data as stored on disk.  All data is
  21. close-packed with no need for byte-padding for word or longword boundaries.
  22.  
  23.  
  24. The SFS Volume Header Record
  25.  
  26. The boot record is the first sector in a disk volume, and is usually used to
  27. load a bootstrap code block which loads more code which eventually loads DOS or
  28. an operating system.  In the case of SFS there is no bootstrap code as SFS
  29. partitions are not bootable.  Instead, the boot record contains a volume header
  30. record holding identification information which SFS uses when mounting the
  31. volume, and encryption information to allow SFS to decrypt the volume.  The
  32. information is stored as a series of variable-length data packets with fields
  33. in big-endian order.  Although it might be desirable to store the data as
  34. DER-encoded ASN.1 (ISO 8824, ISO 8825), the amount of code necessary to decode
  35. this information is considerable, leading to excessively complicated loaders
  36. for the encrypted volume.  In particular, it would make the use of automatic
  37. volume mounts for the SFS device driver virtually impossible.
  38.  
  39. The SFS volume header may contain multiple data packets, currently up to seven
  40. types are implemented (there is an additional eighth pseudo-packet type which
  41. is a null data packet).  One packet identifies the volume, one contains
  42. encryption information needed to en/decrypt the volume, and one contains
  43. filesystem-specific information needed to access the volume.  These packets are
  44. mandatory.  Finally, a number of optional packets may be used to hold data such
  45. as information for volumes accessible by multiple users, information needed by
  46. the high-speed direct disk access routines in SFS, and information to control
  47. the conditions under which SFS volumes are unmounted.  Each packet consists of
  48. a packet type identifier followed by the length of the data in the packet, and
  49. then by the packet data itself.
  50.  
  51. The volume header is laid out as follows:
  52.  
  53.     Offset  Size    Type        Description
  54.  
  55.        0      4     BYTE[ 4 ]   'SFS1' identification string
  56.        4      2     WORD        Information packet 1 ID
  57.        6      2     WORD        Information packet 1 data length
  58.        8     ??     ????        Information packet 1 data
  59.        n      2     WORD        Information packet 2 ID
  60.      n+2      2     WORD        Information packet 2 data length
  61.      n+4     ??     ????        Information packet 2 data
  62.                       ..........
  63.        m      2     WORD        Information packet n ID
  64.      m+2      2     WORD        Information packet n data length
  65.      m+4     ??     ????        Information packet n data
  66.  
  67. It is recommended that the order of the information packets be as follows
  68.  
  69.     1.  Volume information
  70.     2.  Encryption information
  71.     3.  Filesystem information
  72.     4.  Other information (such as multiuser access data, direct disk access
  73.         information, information to control the conditions under which SFS
  74.         volumes are unmounted, and smart card information)
  75.  
  76. although this is not essential.  However some volume mount software which must
  77. run with severely limited resources may run into problems if the order of the
  78. data packets is not as expected.  The remainder of the sector is filled with
  79. zeroes, which correspond to null packets.  Currently defined packet types are:
  80.  
  81.     Name                    Value   Information type
  82.  
  83.     SFS_PACKET_NONE           0     Null packet
  84.     SFS_PACKET_VOLUMEINFO     1     Volume information
  85.     SFS_PACKET_ENCRINFO       2     Encryption information
  86.     SFS_PACKET_DISK_BPB       3     Filesystem information
  87.     SFS_PACKET_MULTIUSER      4     Multiuser access information
  88.     SFS_PACKET_FASTACCESS     5     Direct disk access information
  89.     SFS_PACKET_UNMOUNT        6     Volume unmount information
  90.     SFS_PACKET_SMARTCARD      7     Smart card information
  91.  
  92.  
  93. Packet 0 - Null Packet
  94.  
  95. This packet contains no information and is never explicitly set in an SFS
  96. volume header.  However since the remainder of the header after the actual data
  97. is padded out with zeroes, it can be viewed as containing a succession of null
  98. packets.
  99.  
  100.  
  101. Packet 1 - Volume Information Packet
  102.  
  103. The volume information packet contains the volume name, the volume creation
  104. time, and the volume serial number.  The packet layout is as follows:
  105.  
  106.     Offset  Size    Type        Description
  107.  
  108.        0      2     WORD        Volume information packet ID = 1
  109.        2      2     WORD        Volume information packet data length
  110.        4      2     WORD        Volume name character set identifier
  111.        6      2     WORD        Volume name length
  112.        8     ??     BYTE[]      Volume name
  113.        n      4     LONG        Volume date, stored as seconds since 1970 GMT
  114.      n+4      4     LONG        Volume serial number
  115.  
  116. The character set identifier is one of the following:
  117.  
  118.     Name                    Value   Information type
  119.  
  120.     SFS_CHARSET_ISO646        0     ISO 646/ASCII character set
  121.     SFS_CHARSET_ISO8859_1     1     ISO 8859-1 character set
  122.     SFS_CHARSET_ISO8859_2     2     ISO 8859-2 character set
  123.     SFS_CHARSET_ISO8859_3     3     ISO 8859-3 character set
  124.     SFS_CHARSET_ISO8859_4     4     ISO 8859-4 character set
  125.     SFS_CHARSET_ISO8859_5     5     ISO 8859-5 character set
  126.     SFS_CHARSET_ISO8859_6     6     ISO 8859-6 character set
  127.     SFS_CHARSET_ISO8859_7     7     ISO 8859-7 character set
  128.     SFS_CHARSET_ISO8859_8     8     ISO 8859-8 character set
  129.     SFS_CHARSET_ISO8859_9     9     ISO 8859-9 character set
  130.  
  131. The volume name is stored as an octet string immediately following the
  132. character set and length values.  The recommended maximum length for the volume
  133. name field is 100 octets, in order to allow room for the remainder of the
  134. volume header.
  135.  
  136. The volume creation data is stored as a count of seconds since midnight on 1st
  137. January 1970.  Times are stored relative to GMT, although some operating
  138. systems may have trouble with time zones.
  139.  
  140. The volume serial number is used mainly for identification purposes and has no
  141. special characteristics, but should be unique across volumes.
  142.  
  143.  
  144. Packet 2 - Encryption Information Packet
  145.  
  146. The encryption information packet contains the algorithm identifier of the
  147. encryption algorithm being used, the iteration count used when setting up the
  148. keying information, the initialisation vector (IV) for the disk key, the
  149. encrypted disk key for the volume, and a key check value which may be used to
  150. verify that the correct decryption key has been given. The packet layout is as
  151. follows:
  152.  
  153.     Offset  Size    Type        Description
  154.  
  155.        0      2     WORD        Encryption packet ID = 2
  156.        2      2     WORD        Encryption packet data length
  157.        4      2     WORD        Encryption algorithm identifier
  158.        6      2     WORD        Encryption key setup iteration count
  159.        8     ??     BYTE[]      Disk key IV
  160.        n    128     BYTE[]      Encrypted disk key
  161.    n+128      2     WORD        Key check value
  162.  
  163. The encryption algorithm identifier is one of the following:
  164.  
  165.     Name                    Value   Encryption algorithm type
  166.  
  167.     SFS_ENCRALGO_NONE         0     No encryption
  168.     SFS_ENCRALGO_SHS          1     MDC/SHS
  169.  
  170. The MDC/SHS algorithm uses the Secure Hash Standard as the block transformation
  171. in the MDC encryption algorithm.
  172.  
  173. The size of the disk key IV depends on the encryption algorithm, and is equal
  174. to the block size of the encryption algorithm being used.  In the case of
  175. MDC/SHS this is 160 bits or 20 bytes.
  176.  
  177. The encrypted disk key contains 128 bytes of cryptographically strong random
  178. information whose derivation is given in the section "Generating Random
  179. Numbers" above.  This data may be utilized as required by the encryption
  180. algorithm used for the particular disk volume.  In the case of MDC/SHS the
  181. first 160 bits are used as the master disk IV from which individual sector IV's
  182. are generated as described in the section "The Use of an Initialization
  183. Vector", the next 512 bits are used as the en/decryption key, and the remaining
  184. 352 bits are ignored.  Other algorithms with larger or smaller key spaces may
  185. use this data differently.
  186.  
  187. The key check value is provided to give some warning about an incorrect
  188. password, and should be derived from the encryption key in some nontrivial
  189. manner which makes using the key check in an attack no easier than a standard
  190. known plaintext attack.  In the case of MDC/SHS it is the last two octets in
  191. the key data buffer after the key setup operation has been performed (this
  192. value is never used as part of the encryption key, and is the product of 200
  193. iterations of MDC/SHS over the user key).
  194.  
  195.  
  196. Packet 3 - Filesystem Information Packet
  197.  
  198. The filesystem information packet contains identification information for the
  199. filesystem contained on the encrypted volume followed by encrypted
  200. filesystem-specific information needed to handle the volume.  This information
  201. is highly system-specific.  The packet layout is as follows:
  202.  
  203.     Offset  Size    Type        Description
  204.  
  205.        0      2     WORD        Filesystem information packet ID = 3
  206.        2      2     WORD        Filesystem information packet data length
  207.        4      2     WORD        Filesystem type identifier
  208.        6     ??     BYTE[]      Encrypted filesystem information
  209.  
  210. The filesystem type identifier is one of the following:
  211.  
  212.     Name                    Value   Filesystem type
  213.  
  214.     SFS_FILESYSTEM_NONE       0     No filesystem
  215.     SFS_FILESYSTEM_FAT        1     MSDOS FAT filesystem - BPB data
  216.  
  217. The encrypted MSDOS BPB data record corresponds directly to a standard BIOS
  218. parameter block and is laid out as follows:
  219.  
  220.     Offset  Size    Type        Description
  221.  
  222.        0      2     WORD        Sector size in bytes
  223.        2      1     BYTE        Sectors per cluster
  224.        3      2     WORD        Number of boot sectors
  225.        5      1     BYTE        Number of FAT copies
  226.        6      2     WORD        Number of entries in root directory
  227.        8      2     WORD        16-bit number of sectors on disk
  228.       10      1     BYTE        Media descriptor byte
  229.       11      2     WORD        Number of sectors per FAT
  230.       13      2     WORD        Number of sectors per track
  231.       15      2     WORD        Number of heads
  232.       17      4     LONG        Number of hidden sectors
  233.       21      4     LONG        32-bit number of sectors on disk
  234.  
  235.  
  236. Packet 4 - Multiuser Access Information
  237.  
  238. The multiuser access information packet contains an identification number for
  239. the multiuser access data file needed to access the volume.  This value is
  240. checked against an equivalent one in the access data file to ensure that the
  241. data file corresponds to the volume in question.  In addition the presence of
  242. this packet signals to the user software that the volume has multiuser access
  243. enabled.  The packet layout is as follows:
  244.  
  245.     Offset  Size    Type        Description
  246.  
  247.        0      2     WORD        Multiuser access information packet ID = 4
  248.        2      2     WORD        Multiuser access information packet data length
  249.        4      4     LONG        Multiuser access data file ID
  250.  
  251.  
  252. Packet 5 - Direct Disk Access Information
  253.  
  254. The direct disk access information packet contains information needed by the
  255. disk access routines in SFS to bypass the normal BIOS disk access methods and
  256. interface directly with the drive.  This leads to a significant speed
  257. improvement with disk types which support this access mode, since SFS can
  258. perform en/decryption operations while waiting for disk I/O to complete.  The
  259. packet layout is as follows:
  260.  
  261.     Offset  Size    Type        Description
  262.  
  263.        0      2     WORD        Direct access information packet ID = 5
  264.        2      2     WORD        Direct access information packet data length
  265.        4      2     WORD        Direct access method
  266.        6     ??     ??          Extra information needed for direct access
  267.  
  268. The direct access method is one of the following:
  269.  
  270.     Name                    Value   Access mode
  271.  
  272.     SFS_ACCESSMODE_BIOS       0     BIOS disk access (default)
  273.     SFS_ACCESSMODE_IDE        1     IDE single-sector programmed I/O access
  274.     SFS_ACCESSMODE_SCSI       2     SCSI device access via ASPI interface
  275.     SFS_ACCESSMODE_LBA        3     LBA access via EIDE interface
  276.     SFS_ACCESSMODE_CDROM      4     CDROM encrypted volume file
  277.     SFS_ACCESSMODE_AUDIO      5     CD audio file via steganography
  278.  
  279. Some of the high-speed access modes are not used automatically since it is
  280. unsafe to assume that all hardware will support them.  Therefore if the direct
  281. disk access information packet is absent and if BIOS access to the drive is
  282. possible, slower BIOS accesses are used by default.  If it has been determined
  283. by external software that a fast access mode is possible, the software should
  284. write (or update) a direct disk access information packet to reflect this.  If
  285. no access to the drive other than with a fast direct access mode is possible,
  286. then the fast access mode will always be used.
  287.  
  288.  
  289. Packet 6 - Volume Unmount Information
  290.  
  291. The volume unmount information packet contains information on conditions under
  292. which SFS volumes are unmounted by the SFS driver.  These may be in response to
  293. external stimuli, or due to internal conditions monitored by the driver.  In
  294. the absence of this packet, the settings used for volume unmounts are the
  295. defaults set by the driver, although these can generally be overridden under
  296. user control.
  297.  
  298. Currently two parameters, the auto-unmount timeout value and smart card removal
  299. actions, are defined.  The packet layout is as follows:
  300.  
  301.     Offset  Size    Type        Description
  302.  
  303.        0      2     WORD        Volume unmount information packet ID = 6
  304.        2      2     WORD        Volume unmount information packet data length
  305.        4      2     WORD        Auto-unmount timeout in minutes, 0 = none set
  306.        6      2     WORD        Smart card unmount action
  307.  
  308. The auto-unmount timeout value  contains the default setting for the
  309. auto-unmount timer for this volume.  If no disk access takes place in the
  310. specified time, the volume is automatically unmounted.  A value of 0 in this
  311. field indicates that no auto-unmount timer is to be set (although this is
  312. better accomplished by simply deleting the volume unmount information packet).
  313.  
  314. The smart card unmount action specifies the action which will be performed on
  315. the volume when the smart card associated with it is removed from the card
  316. reader.  If the volume doesn't use a smart card, no action will be performed.
  317. The unmount actions are as follows, and are explained in more detail in the
  318. section "Controlling SFS Volumes with Smart Cards" above:
  319.  
  320.     Name                    Value   Unmount action
  321.  
  322.     SFS_CARD_UMT_NONE         0     Do nothing (also used when no smart card is
  323.                                     used for the volume)
  324.     SFS_CARD_UMT_RO           1     Make the volume readonly if card is removed
  325.     SFS_CARD_UMT_THIS         2     Unmount the volume if card is removed
  326.     SFS_CARD_UMT_ALL          3     Unmount all volumes is card is removed
  327.  
  328.  
  329. Packet 7 - Smart Card Information
  330.  
  331. The smart card information packet contains information used to tie a particular
  332. smart card to an SFS volume.  The packet layout is as follows:
  333.  
  334.     Offset  Size    Type        Description
  335.  
  336.        0      2     WORD        Smart card information packet ID = 6
  337.        2      2     WORD        Smart card information packet data length
  338.        4      2     WORD        Smart card type (0 = none, 1 = basic 256-byte
  339.                                 memory card).
  340.        6      4     LONG        Smart card serial number
  341.  
  342. The smart card type is used to tell the software how to communicate with the
  343. card associated with the volume, since many cards cannot identify themselves
  344. properly or can't even be accessed without the correct key.  Currently two
  345. types are defined, a no-card type 0 and a basic 256-byte memory card controlled
  346. via the I2C bus protocol with card type 1.
  347.  
  348. The smart card serial number is used to tie the volume to the card with the
  349. given serial number.
  350.  
  351.  
  352. SFS Multiuser Access File Layout
  353. --------------------------------
  354.  
  355. [The following information is preliminary and is bound to change at a moments
  356.  notice]
  357.  
  358. Associated with each SFS volume which has multiuser access enabled are one or
  359. more database files containing information on each user who has access to that
  360. volume.  This consists of identification information for each user (in the case
  361. of a named database), access control information, and keying information needed
  362. to access the actual volume.
  363.  
  364. The file is laid out as a simple flat database, which is adequate for its
  365. intended use since a user record is only retrieved once per database access,
  366. and generally the databases will be quite small.
  367.  
  368. On a system with proper access control this file will be read-only for everyone
  369. but the volume administrator, but unfortunately under some operating systems
  370. and also DOS there is little access control and anyone with access to a sector
  371. editor can change their access rights.  However at this level they can also
  372. change the SFS volume header and the behaviour of mountsfs and the SFS driver,
  373. so little is gained by attempting to plug this hole.  In any case, the basic
  374. access to the volume is cryptographically controlled, and bypassing this goes
  375. beyond simply editing a file.
  376.  
  377. In the future it may be worthwhile implementing more heavy-duty controls, such
  378. as using public-key signed access permission tokens from the volume
  379. administrator to grant access for networked use.
  380.  
  381. All data in the multiuser access database is stored in big-endian format
  382. following the convention used by international cryptographic standards.  Care
  383. should to taken to ensure that the proper endianness is maintained when reading
  384. and writing the boot sector on little-endian systems (the performance of the
  385. current implementation was tested against the RS6000 version to confirm that
  386. endianness conversion was being done correctly).
  387.  
  388. In the following discussion a BYTE is an 8-bit quantity, a WORD is a big-
  389. endian 16-bit quantity, and a LONG is a big-endian 32-bit quantity.  There are
  390. no alignment restrictions for the data as stored in the database.  All data is
  391. close-packed with no need for byte-padding for word or longword boundaries.
  392.  
  393. An access database is broken up into two sections, a header record containing
  394. details on the database as a whole, and one or more individual user records.
  395.  
  396.  
  397. Database Header
  398.  
  399. The database header is laid out as follows:
  400.  
  401.     Offset  Size    Type        Description
  402.  
  403.        0      4     BYTE[4]     'SFS1' identification string
  404.        4      2     WORD        Database type identifier
  405.        6      4     LONG        Encrypted volume serial number
  406.       10      2     WORD        Number of user records in database
  407.       12      2     WORD        Database name character set identifier
  408.       14      2     WORD        Database name length
  409.       16     ??     BYTE[]      Database name
  410.  
  411. The identification string and database type identifier serve to identify the
  412. general database format.  The type identifier is one of the following:
  413.  
  414.     Value   Type
  415.  
  416.       0     Anonymous database containing date, access, keyinfo records
  417.       1     Named database containing user name, date, access, keyinfo records
  418.      ??     Reserved for future use
  419.  
  420. An anonymous database contains no identification for any of the user records.
  421. Each keyinfo record is decrypted in turn until a valid record is found, and
  422. this keying information is then used to access the encrypted volume.
  423.  
  424. A named database contains an idetifier for each user record.  Lookup of the
  425. database is performed directly by user name, and then access proceeds as for
  426. the anonymous database.
  427.  
  428. The encrypted volume serial number is the serial number of the volume this
  429. database is used to access.
  430.  
  431. [Problem: Should be able to set to zero to keep corresponding volume anonymous]
  432. [Problem: Can lead to trouble if chsfs is used to change volume serial number.
  433.           Perhaps change chsfs to disallow serial number change without also
  434.           changing database serial number]
  435.  
  436. The database name is the collective name for the database and the users in it.
  437. Example database names might be "Ancient Illuminated Seers of Bavaria" or
  438. "Trilateral Commission".  The name is optional, and may be omitted by
  439. specifying a name with a length of 0 characters.
  440.  
  441.  
  442. Database Records
  443.  
  444. Each record in the database is laid out as follows:
  445.  
  446.     Offset  Size    Type        Description
  447.  
  448.        0      2     WORD        Record type identifier
  449.        2      2     WORD        User name character set identifier
  450.        4      2     WORD        User name length
  451.        6     ??     BYTE[]      User name
  452.        n      4     LONG        Access valid from date
  453.      n+4      4     LONG        Access valid to date
  454.      n+8      4     LONG        Access rights bitstring
  455.     n+12     ??     BYTE[]      Keying information
  456.  
  457. The record type identifier is one of the following:
  458.  
  459.     Value   Type
  460.  
  461.       0     Anonymous record containing date, access, and keyinfo
  462.       1     Named record containing user name, date, access, and keyinfo
  463.      ??     Reserved for future use
  464.  
  465. The user name is the name of the user entitled to access the SFS volume the
  466. database corresponds to.  Under multiuser operating systems this will simply
  467. correspond to the userID which the user is known to the operating system under.
  468. Otherwise, the userID can be the user's name or some similar identifying method
  469. capable of distinguishing users.  If the record type is an anonymous record,
  470. the user name fields will not be present.
  471.  
  472. [Problem: One user with many accounts.  Allow multiple userID's per record?
  473.           This could encourage password sharing though]
  474.  
  475. The access valid date pair contains the date after which access to the SFS
  476. volume is permitted, and the date at which access rights to the volume expire.
  477. These are stored in the Unix seconds-since-1970 format.
  478.  
  479. The access rights bitstring contains the access rights the user has to the SFS
  480. volume.
  481.  
  482. [Problem: How?  Use RWXRWXRWX?  Or ASN.1-type strings with complex FTAM-type
  483.           rights?  ACL's?]
  484.  
  485. The keying information is [what?  Same as single-user keying information]
  486.  
  487.  
  488. SFS Share File Layout
  489. ---------------------
  490.  
  491. Associated with all SFS volumes which have key escrow or anti-duress measures
  492. enabled is a database of shares needed to reconstruct key components to access
  493. the volumes.  The database may contain a number of share records (if used for
  494. anti-duress measures), or an individual share (if used for key escrow
  495. purposes).  The file is laid out as a simple flat database, which is adequate
  496. for its intended use since it is traversed only once until enough shares have
  497. been accumulated to gain access to a volume.
  498.  
  499. A share database is broken up into two sections, a header data packet
  500. containing details on the database as a whole, and one or more share packets
  501. containing the shares themselves.  All the shares in one database apply to a
  502. specific volume, but may consist of many seperate share groups.  There are two
  503. values used to identify shares, the first one in the database header is the
  504. volume identifier of the SFS volume the shares apply to and is used to
  505. associate the shares with a particular SFS volume.  The second is stored with
  506. each share and is used to tie it to other shares in the same share group.  By
  507. varying the share group identifier, multiple groups of shares can be stored in
  508. the same database.
  509.  
  510. A share database contains multiple data packets, currently up two types are
  511. implemented (there is an additional third pseudo-packet type which is a null
  512. data packet).  Each packet consists of a packet type identifier followed by the
  513. length of the data in the packet, and then by the packet data itself.
  514.  
  515. The share database is laid out as follows:
  516.  
  517.     Offset  Size    Type        Description
  518.  
  519.        0      4     BYTE[4]     'SFS1' application identification string
  520.        4      4     BYTE[4]     'SDBX' file type identification string
  521.        8      2     WORD        Share database header packet ID
  522.       10      2     WORD        Share database header packet data length
  523.       12     ??     ????        Share database header packet
  524.        n      2     WORD        Share packet 1 ID
  525.      n+2      2     WORD        Share packet 1 data length
  526.      n+4     ??     ????        Share packet 1 data
  527.        n      2     WORD        Share packet 2 ID
  528.      n+2      2     WORD        Share packet 2 data length
  529.      n+4     ??     ????        Share packet 2 data
  530.                       ..........
  531.        m      2     WORD        Share packet n ID
  532.      m+2      2     WORD        Share packet n data length
  533.      m+4     ??     ????        Share packet n data
  534.  
  535. Currently defined share packet types are:
  536.  
  537.     Name                    Value       Information type
  538.  
  539.     SFS_SHARE_PACKET_NONE     0         Null packet
  540.     SFS_SHARE_PACKET_DBASEHDR 1         Share database header
  541.     SFS_SHARE_PACKET_SHARE    2         Individual share
  542.  
  543.  
  544. Packet 0 - Null Packet
  545.  
  546. This packet contains no information and is never explicitly set in an SFS
  547. volume header.  However since the remainder of the header after the actual data
  548. is padded out with zeroes, it can be viewed as containing a succession of null
  549. packets.
  550.  
  551.  
  552. Packet 1 - Share Database Header Packet
  553.  
  554. The volume information packet contains the volume name, the volume creation
  555. time, and the volume serial number.  The packet layout is as follows:
  556.  
  557. The share database header packet contains information about the database as a
  558. whole, and is laid out as follows:
  559.  
  560.     Offset  Size    Type        Description
  561.  
  562.        0      2     WORD        Share database header packet ID = 1
  563.        2      2     WORD        Share database header packet data length
  564.        4      4     LONG        Database identifier
  565.        8      2     WORD        Number of share records in the database
  566.       10      2     WORD        Number of shares needed to reconstruct the
  567.                                 shared secret
  568.       12      2     WORD        CRC16 of data fields in record
  569.  
  570. The database identifier is the volume identifier of the SFS volume which this
  571. share database applies to.
  572.  
  573. The count of the total number of shares in the database is useful for
  574. bookkeeping purposes.
  575.  
  576. The number of shares needed to reconstruct the shared secret gives the
  577. threshold value for the (M,N) threshold scheme used to implement the share
  578. database.
  579.  
  580. The CRC16 value covers the data fields from the field following the record
  581. length to the field preceding the checksum value inclusive, and is used for
  582. error control as shares may be communicated over unreliable channels.
  583.  
  584.  
  585. Packet 2 - Individual share
  586.  
  587. Each record in the share database is laid out as follows:
  588.  
  589.     Offset  Size    Type        Description
  590.  
  591.        0      2     WORD        Individual share packet ID = 2
  592.        2      2     WORD        Individual share packet data length
  593.        4      4     LONG        Share group identifier
  594.        8      2     WORD        Share record type
  595.       10     ??     BYTE[]      Share record
  596.        n      2     WORD        CRC16 of data fields in record
  597.  
  598. The share group identifier is a value used to connect all shares belonging to
  599. the same share group in the share database.  Multiple groups of shares may be
  600. stored in a database by giving each group a different share group identifier.
  601.  
  602. The share record type defines the format of the share record which follows it,
  603. and may be one of the following:
  604.  
  605.     Name                        Value       Information type
  606.  
  607.     SFS_SHARETYPE_NONE            0         Null share type
  608.     SFS_SHARETYPE_LAGRANGE        1         LaGrange interpolating polynomial
  609.                                             scheme
  610.     SFS_SHARETYPE_LAGRANGE_ENCR   2         LaGrange interpolating polynomial
  611.                                             scheme with encryption
  612.  
  613. The share record may contain unencrypted data used for key escrow purposes, or
  614. encrypted data used for anti-duress measures.  The format of the share record
  615. is explained below.
  616.  
  617. The CRC16 value covers the data fields from the field following the record
  618. length to the field preceding the checksum value inclusive, and is used for
  619. error control as shares may be communicated over unreliable channels.
  620.  
  621.  
  622. Share Records
  623.  
  624. The share record is an integral part of an individual share packet and has no
  625. length or checksum field associated with it.
  626.  
  627. The SFS_SHARETYPE_NONE share record is a null record type containing no
  628. information.
  629.  
  630. The SFS_SHARETYPE_LAGRANGE polynomial scheme share record is laid out as
  631. follows:
  632.  
  633.     Offset  Size    Type        Description
  634.  
  635.        0      2     WORD        Share record ID = 1
  636.        2      4     WORD        Share number
  637.        6     ??     BYTE[]      Share data
  638.  
  639. The share number is the X coordinate and the share data itself is the Y
  640. coordinates.
  641.  
  642. The SFS_SHARETYPE_LAGRANGE_ENCR polynomial scheme with encryption share record
  643. is laid out as follows:
  644.  
  645.     Offset  Size    Type        Description
  646.  
  647.        0      2     WORD        Share record ID = 2
  648.        2      4     WORD        Share number
  649.        6      2     WORD        Share encryption algorithm identifier
  650.        8     ??     BYTE[]      Share record IV
  651.        n     ??     BYTE[]      Encrypted share
  652.      n+m      2     WORD        Share check value
  653.  
  654. The share encryption algorithm identifier is as given in the section "SFS Disk
  655. Volume Layout" above.  An encryption type of SFS_ENCR_ALGO_ID_NONE is
  656. equivalent to an SFS_SHARETYPE_LAGRANGE share record which has no provision for
  657. encryption.
  658.  
  659. The size of the share record IV depends on the encryption algorithm, and is
  660. equal to the block size of the encryption algorithm being used.  If no
  661. encryption is used, the IV field is not present.  If MDC/SHS is used, the IV is
  662. 160 bits or 20 bytes.
  663.  
  664. The share number is the X coordinate and the share data itself is the Y
  665. coordinates.  The validity of the decrypted Y coordinate is checked using the
  666. share check value.  Details of this are still uncertain as it is only needed
  667. for anti-duress measures, which are currently disabled.
  668.  
  669.  
  670. SFS Smart Card Data Layout
  671. --------------------------
  672.  
  673. SFS stores the keying information it needs to access a volume in smart cards as
  674. explained in the "Design Details" section above.  Since some cards have a
  675. limited amount of internal storage, SFS uses either the standard
  676. variable-length record format which follows the format used for volume headers,
  677. multiuser access files, and share files, or a compressed format containing the
  678. minimal information needed to work with the card.  Only the standard card
  679. format will be covered here.
  680.  
  681. The smart card may contain multiple data packets, currently up two types are
  682. implemented (there is an additional third pseudo-packet type which is a null
  683. data packet).  One packet identifies the card in the much the same way that a
  684. volume information packet identifies a disk volume, and the other contains
  685. the encryption information needed to en/decrypt the disk key stored in the
  686. volume header.  Each packet consists of a packet type identifier followed by
  687. the length of the data in the packet, and then by the packet data itself.
  688.  
  689. The card is laid out as follows:
  690.  
  691.     Offset  Size    Type        Description
  692.  
  693.        0      4     BYTE[4]     'SFS1' application identification string
  694.        4      4     BYTE[4]     'CARD' data type identification string
  695.        8      2     WORD        Information packet 1 ID
  696.       10      2     WORD        Information packet 1 data length
  697.       12     ??     ????        Information packet 1 data
  698.        n      2     WORD        Information packet 2 ID
  699.      n+2      2     WORD        Information packet 2 data length
  700.      n+4     ??     ????        Information packet 2 data
  701.                       ..........
  702.        m      2     WORD        Information packet n ID
  703.      m+2      2     WORD        Information packet n data length
  704.      m+4     ??     ????        Information packet n data
  705.  
  706. The remainder of the card is filled with zeroes, which correspond to null
  707. packets.  Currently defined card packet types are:
  708.  
  709.     Name                    Value       Information type
  710.  
  711.     SFS_CARD_PACKET_NONE      0         Null packet
  712.     SFS_CARD_PACKET_CARDINFO  1         Card information
  713.     SFS_CARD_PACKET_ENCRINFO  2         Encryption information
  714.  
  715.  
  716. Packet 0 - Null Packet
  717.  
  718. This packet contains no information and is never explicitly set in an SFS smart
  719. card.  However since the remainder of the card memory after the actual data is
  720. padded out with zeroes, it can be viewed as containing a succession of null
  721. packets.
  722.  
  723.  
  724. Packet 1 - Card Information Packet
  725.  
  726. The card information packet contains the cards serial number and a flag to
  727. indicate whether it is a cloneable master card or a non-cloneable slave card.
  728. The packet layout is as follows:
  729.  
  730.     Offset  Size    Type        Description
  731.  
  732.        0      2     WORD        Card information packet ID = 1
  733.        2      2     WORD        Card information packet data length
  734.        4      2     LONG        Card serial number
  735.        6      2     WORD        Card master flag (0 = slave, 1 = master)
  736.  
  737. The card serial number is used to tie the card to the volume it is used to
  738. access.
  739.  
  740. The card master flag is used to indicate whether a card is cloneable or not.
  741. If this value is 0, the card is a slave card and cannot be cloned.  If the
  742. value is 1, the card is a master card and can be cloned to produce more slave
  743. cards.
  744.  
  745. Packet 2 - Encryption Information Packet
  746.  
  747. This packet type is identical to the encryption information packet described in
  748. the "SFS Disk Volume Layout" section above.
  749.  
  750.  
  751. Interfacing with SFS
  752. --------------------
  753.  
  754. The SFS device driver has a sophisticated control interface which allows
  755. complete configurability through the standard DOS IOCTL read and write calls,
  756. which are used to transfer data to and from the control channel of a device.
  757. It is recommended that you consult a system programming guide or your compilers
  758. documentation for more information on making DOS IOCTL calls.  Many compilers
  759. provide standard routines for making these calls.
  760.  
  761. In the following discussion a BYTE is an 8-bit quantity, a WORD is a little-
  762. endian 16-bit quantity, and a LONG is a little-endian 32-bit quantity.  These
  763. values will need endianness conversion after being read from the SFS volume
  764. header.
  765.  
  766.  
  767. How SFS Identifies Drives
  768.  
  769. For floppy disk drives, a value of 0 usually corresponds to drive A: and a
  770. value of 1 usually corresponds to drive B:.  For fixed disk drives accessible
  771. through the system BIOS, a value of 0 with the high bit set (giving an actual
  772. value of 0x80) usually corresponds to the first physical drive and a value of 1
  773. with the high bit set (giving an actual value of 0x81) usually corresponds to
  774. the second physical drive.  These values correspond to physical drives as
  775. accessed through the BIOS, and not logical volumes (SFS can also access drives
  776. not normally accessible through the BIOS).  A single physical drive may contain
  777. a number of logical volumes. Since the SFS driver runs below the level at which
  778. most operating systems operate, it will ignore the DOS drive mappings (in fact
  779. DOS can't even see the encrypted disk volume) and access the drive directly.
  780. Thus if there are more than the DOS standard of two floppy drives and two
  781. physical hard drives connected to the system it should still be able to access
  782. the drives and present them to the operating system as normal disk volumes.
  783.  
  784. If the physical drive contains more than one logical volume, the offset of the
  785. start of the logical volume from the start of the physical drive is specified
  786. as a sector or disk block count.  If the physical drive contains only one
  787. logical volume, this value is set to zero.  Finding the start of the logical
  788. volume will usually entail parsing the partition table of the physical drive.
  789. Floppy drives have only one logical volume which is equivalent in size to the
  790. physical drive, fixed disks have one or more logical volumes on each physical
  791. volume.  These logical volumes can contain different filesystems and operating
  792. systems, and not all may be accessible or visible to DOS.  For more information
  793. on disk organization, refer to a good technical reference which covers disk
  794. drives, and then spend several days figuring out all the DOS quirks never
  795. mentioned in any reference.
  796.  
  797. In the following text the term `drive number' is used to refer to a value which
  798. identifies a particular drive (which depends on the drive type, since BIOS, IDE
  799. and SCSI drive access identifies drives in different ways), the term `physical
  800. volume' is used to refer to the physical drive being accessed and the term
  801. `logical volume' is used to refer to the drive as DOS sees it.
  802.  
  803.  
  804. Reading from the SFS Driver:
  805.  
  806. The SFS driver processes both control channel read and control channel write
  807. requests.  Initially, the drive number of the logical volume being used by the
  808. SFS driver must be found.  This can be done by checking each possible logical
  809. drive as follows:
  810.  
  811.     for( driveNumber = 0; driveNumber <= 'Z' - 'A'; driveNumber++ )
  812.         {
  813.         /* Try and read data from the device's control channel */
  814.         data <- ioctlRead( driveNumber );
  815.  
  816.         /* Check for the SFS identification string */
  817.         if( first 4 bytes of data = 'SFS1' )
  818.             exit loop;
  819.         }
  820.  
  821. If, at the end of the loop's execution, the driveNumber is greater than the
  822. total number of drives in the system, the SFS driver has not been found,
  823. probably because it isn't present in the system.  Otherwise, driveNumber
  824. contains the drive number of the logical volume which the SFS driver is making
  825. available, and the data packet contains assorted status information about the
  826. SFS volume corresponding to the driveNumber.
  827.  
  828. The data packet returned by the SFS driver is as follows:
  829.  
  830.     Offset  Size    Type        Description
  831.  
  832.        0      4     BYTE[ 4 ]   'SFS1' identification string
  833.        4      2     WORD        SFS unit number, starting from 0
  834.        6      2     WORD        Drive the SFS volume is mounted on.
  835.                                 Interpretation of this value depends on the
  836.                                 disk access mode.
  837.        8      4     LONG        Sector or disk block offset of logical volume
  838.                                 from start of physical volume, or 0 if logical
  839.                                 volume corresponds to physical volume
  840.       12      2     WORD        0 = no disk mounted, 1 = disk mounted, 2 = disk
  841.                                 mounted in non-removable mode
  842.       14      2     WORD        0 = disk is read/write, 1 = disk is read-only
  843.       16      2     WORD        Quick-unmount hotkey value (high byte = shift
  844.                                 value, low byte = optional keyboard scan code)
  845.       18      2     WORD        Auto-unmount time.  -1 = no unmount timer set,
  846.                                 0 = timer set but expired, any other value =
  847.                                 total unmount time in minutes
  848.       20      2     WORD        Auto-unmount timeout actual minutes remaining
  849.                                 before the unmount takes place
  850.       22      2     WORD        Internal driver check code.  0 = no error, 1 =
  851.                                 driver consistency check failed, 2 = individual
  852.                                 unit consistency check failed.
  853.       24      4     LONG        Last I/O error status - see below.
  854.       28      2     WORD        Smart card status - see below.
  855.  
  856. The unit number is used by SFS to handle multiple encrypted drives.  This value
  857. starts at zero for the first unit, and identifies the volume being accessed.
  858.  
  859. The last I/O error status value provides more details on the last read or write
  860. error encountered by the SFS driver for the drive in question.  This value is
  861. divided into 4 bytes, of which the first contains the access mode in use when
  862. the error occurred, the the remaining three contain error information.  The
  863. possible values are as follows:
  864.  
  865.     First byte  Access mode     Remaining bytes
  866.  
  867.         0          BIOS         Byte 1 = 0
  868.                                 Byte 2 = 0
  869.                                 Byte 3 = BIOS error code
  870.         1          IDE          Byte 1 = 0
  871.                                 Byte 2 = controller status
  872.                                 Byte 3 = controller error code
  873.         2          SCSI         Byte 1 = sense key
  874.                                 Byte 2 = auxiliary sense key
  875.                                 Byte 3 = auxiliary sense key qualifier
  876.        ??        Reserved       Reserved for future use
  877.  
  878. In all cases a value of all ones in bytes 2 and 3 indicate a controller or host
  879. device timeout.
  880.  
  881. The smart card status value contains information on the driver's handling of
  882. the smart card as it applies to the current volume.  Currently defined status
  883. values are:
  884.  
  885.     Name                    Value       Information type
  886.  
  887.     CARD_STATUS_NONE          0         No card present
  888.     CARD_STATUS_INERT         1         Card present but unused
  889.     CARD_STATUS_ACTIVE        2         Card active, but not for this volume
  890.     CARD_STATUS_RO_THIS       3         Card active, volume will become
  891.                                         read-only if card is removed
  892.     CARD_STATUS_UMT_THIS      4         Card active, volume will be unmounted
  893.                                         if card is removed
  894.     CARD_STATUS_UMT_ALL       5         Card active, all volumes will be
  895.                                         unmounted if card is removed
  896.     CARD_STATUS_SUSPENDED     6         Card handling has been temporarily
  897.                                         suspended to allow other software to
  898.                                         use the card reader
  899.  
  900. A return value of CARD_STATUS_ACTIVE implies that a card is present and in use
  901. by the driver, but that this use does not apply to the current volume.  If the
  902. card in use does apply to the current volume, a value of CARD_STATUS_RO_THIS,
  903. CARD_STATUS_UMT_THIS, or CARD_STATUS_UMT_ALL will be returned instead of
  904. CARD_STATUS_ACTIVE.
  905.  
  906. If queried via an IOCTL call on the volume's removability, the SFS driver will
  907. always indicate that the media is removable, even if the volume is on a fixed
  908. disk.  This is because some disk cacheing software won't invalidate a drive's
  909. data, even if the driver signals that the media has changed, unless the volume
  910. is marked as being removable.
  911.  
  912. This status information can be returned to the user in the form of a status
  913. message or an information dialog if desired (the drive and offset information
  914. can be used to read the volume name, date, and serial number from the encrypted
  915. volume).
  916.  
  917.  
  918. Writing to the SFS Driver
  919.  
  920. Once the driver has been found, several types of data packet can be sent to the
  921. driver to control its operation.  Each control packet begins with a WORD
  922. containing the magic value 'C0' which the SFS driver checks to ensure the
  923. packet is meant for it, and a WORD identifying the data packet type.  The data
  924. packet types are:
  925.  
  926.     Name                    Value       Information type
  927.  
  928.     PACKET_SET_DISKINFO       0         Disk parameters
  929.     PACKET_SET_KEYINFO        1         Keying information
  930.     PACKET_SET_READONLY       2         Set disk read-only status
  931.     PACKET_SET_DRIVENO        3         Drive number to mount
  932.     PACKET_SET_MOUNTSTATUS    4         Set mount status
  933.     PACKET_SET_UNMOUNT        5         Set/clear quick-unmount hotkey value
  934.     PACKET_SET_TIMEOUT        6         Set/clear timed unmount value
  935.     PACKET_WIN_CLOCKTICK      7         Windows clock tick packet
  936.     PACKET_SET_CARDINFO       8         Smart card control information
  937.  
  938. These packets are explained in more detail below.  All other values are
  939. reserved for future use.
  940.  
  941.  
  942. Packet 0 - Disk Parameters:
  943.  
  944. This packet type is used to convey to the SFS driver various pieces of
  945. information about the physical characteristics of the disk drive, including the
  946. sector size, number of heads, total number of sectors, and so on.  The packet
  947. layout is as follows:
  948.  
  949.     Offset  Size    Type        Description
  950.  
  951.        0      2     WORD        Magic value 'C0'
  952.        2      2     WORD        Packet type 0, PACKET_SET_DISKINFO
  953.        4     25     BYTE[]      BPB record
  954.  
  955. The BPB record is the information from the BIOS parameter block as defined in
  956. the section "SFS Disk Volume Layout" above.
  957.  
  958. Sending this data packet to the driver automatically unmounts the encrypted
  959. volume.
  960.  
  961.  
  962. Packet 1 - Keying Information
  963.  
  964. This packet type sets up the encryption information in the driver.  It contains
  965. the en/decryption key, and the master IV for the encrypted volume.  The packet
  966. layout is as follows:
  967.  
  968.     Offset  Size    Type        Description
  969.  
  970.        0      2     WORD        Magic value 'C0'
  971.        2      2     WORD        Packet type 1, PACKET_SET_KEYINFO
  972.        4     20     BYTE[ 20 ]  Master IV for encrypted volume
  973.       24     64     BYTE[ 64 ]  MDC/SHS keying information
  974.  
  975. Sending this data packet to the driver automatically unmounts the encrypted
  976. volume.
  977.  
  978.  
  979. Packet 2 - Set disk Read-only Status
  980.  
  981. This packet type sets the read-only status of the disk.  Sending a value of 0
  982. makes the disk read-only.  Sending a value of 1 makes the disk read/write.  The
  983. packet layout is as follows:
  984.  
  985.     Offset  Size    Type        Description
  986.  
  987.        0      2     WORD        Magic value 'C0'
  988.        2      2     WORD        Packet type 2, PACKET_SET_READONLY
  989.        4      2     WORD        Read-only status: 0 = read-only, 1 = read/write
  990.  
  991. Sending this packet type has no effect on the mount status of the volume.
  992.  
  993.  
  994. Packet 3 - Drive Number to Mount
  995.  
  996. This packet type sets the drive number and the offset of the logical volume on
  997. the physical drive, which the driver will en/decrypt.  The packet layout is as
  998. follows:
  999.  
  1000.     Offset  Size    Type        Description
  1001.  
  1002.        0      2     WORD        Magic value 'C0'
  1003.        2      2     WORD        Packet type 3, PACKET_SET_DRIVENO
  1004.        4      2     WORD        Drive number.  Interpretation of this value
  1005.                                 depends on the disk access mode.
  1006.        6      4     LONG        Sector or disk block offset of logical volume
  1007.                                 from start of physical volume, or 0 if logical
  1008.                                 volume corresponds to physical volume
  1009.  
  1010. The drive number contains information allowing the driver to locate the
  1011. physical drive on which the SFS volume is located.  The drive access mode and
  1012. drive identifying information are encoded into a 16-bit word as follows:
  1013.  
  1014.     Bits 15-12: Disk access mode
  1015.     Bits 11-0 : Drive identifying information
  1016.  
  1017. The drive identifying information is laid out as follows:
  1018.  
  1019.     Access mode     Drive identifying informtion
  1020.  
  1021.          0          Bits 11-8: 0
  1022.                     Bits 7-0 : BIOS drive number
  1023.          1          Bits 11-8: 0
  1024.                     Bits 7-0 : IDE drive number
  1025.          2          Bits 11-8: SCSI host number
  1026.                     Bits 7-4 : SCSI target ID
  1027.                     Bits 3-0 : SCSI logical unit number
  1028.  
  1029. Sending this data packet to the driver automatically unmounts the encrypted
  1030. volume.
  1031.  
  1032.  
  1033. Packet 4 - Set mount Status
  1034.  
  1035. This packet type sets the mount status of the drive.  A value of 0 unmounts the
  1036. drive, a value of 1 mounts the drive.  The packet layout is as follows:
  1037.  
  1038.     Offset  Size    Type        Description
  1039.  
  1040.        0      2     WORD        Magic value 'C0'
  1041.        2      2     WORD        Packet type 4, PACKET_SET_MOUNTSTATUS
  1042.        4      2     WORD        Mount status (0 = unmount, 1 = mount)
  1043.  
  1044. Unmounting the drive using this packet type also destroys the encryption
  1045. information held by the driver and forces all data still held in cache and disk
  1046. buffers to be flushed to disk.  This is the only sure way to erase all the
  1047. encryption information, as it wipes not only the actual keying information but
  1048. also most of the data area used by the driver and any data in cache and disk
  1049. buffers.  Merely sending an empty keying information packet will not perform
  1050. this task.
  1051.  
  1052.  
  1053. Packet 5 - Set/clear Quick-Unmount Hotkey Value
  1054.  
  1055. This packet is used to set the hotkey value which the SFS driver checks for to
  1056. quickly unmount an SFS volume, or to clear the hotkey handling.  The packet
  1057. layout is as follows:
  1058.  
  1059.     Offset  Size    Type        Description
  1060.  
  1061.        0      2     WORD        Magic value 'C0'
  1062.        2      2     WORD        Packet type 5, PACKET_SET_UNMOUNT
  1063.        4      2     WORD        Hotkey value (see below)
  1064.  
  1065. The hotkey which the driver checks for can be any combination of the alt key,
  1066. control key, left shift, and right shift (referred to as the shift code), and
  1067. an arbitrary keyboard scan code.  The recommended default value is a
  1068. combination of the left and right shift keys.  This information is encoded in
  1069. the hotkey WORD as follows:
  1070.  
  1071.   The high 8 bits contain the shift code.  This contains a set of bitflags
  1072.   which specify the shift keys the driver checks for, possibly in addition to
  1073.   an optional character code.  The values are:
  1074.  
  1075.         Shift key       Value (binary)      Value (hex)
  1076.  
  1077.            Alt             00001000             08
  1078.          Control           00000100             04
  1079.        Left Shift          00000010             02
  1080.       Right Shift          00000001             01
  1081.  
  1082.   The encoding for the shift code portion of the default left+right shift
  1083.   hotkey is therefore 00000011 binary or 03 hex.
  1084.  
  1085.   The low 8 bits contain an optional keyboard scan code which the driver will
  1086.   check for in addition to the shift code.  This value is used in combination
  1087.   with the shift code to specify a key combination to the driver, so that for
  1088.   example Alt-Z would be used as the quick-unmount hotkey, although care should
  1089.   be taken to ensure that none of a large number of existing special key
  1090.   combinations is reused for this.
  1091.  
  1092.   If the low 8 bits contain zeroes, the driver does not check for a keyboard
  1093.   scan code in addition to a shift code.  The encoding for the keyboard scan
  1094.   code portion of the default left+right shift hotkey is therefore 00000000
  1095.   binary or 00 hex.
  1096.  
  1097.   The overall value is the combination of the shift code and keyboard scan
  1098.   code, or 0300 hex for the default hotkey.
  1099.  
  1100. Specifying a value of 0 in this word will disable hotkey checking in the
  1101. driver.
  1102.  
  1103. The hotkey quick-unmount is handled by hooking the int 9h keyboard interrupt.
  1104. The interrupt handler which performs this task is installed either when the
  1105. driver is loaded (if there is a volume to be mounted or a hotkey code is
  1106. specified), or when mountsfs is run (which transmits a quick-unmount control
  1107. packet to the driver).  The interrupt handler checks for the programmed hotkey
  1108. and unmounts the volume if it is detected.  Subsequent quick-unmount control
  1109. packets can be sent to the driver to change the actual hotkey value.  Sending a
  1110. value of 0 will disable hotkey checking and deinstall the keyboard interrupt
  1111. handler.
  1112.  
  1113.  
  1114. Packet 6 - Set/clear Timed Unmount Value
  1115.  
  1116. This packet is used to set the unmount time after which an SFS volume is
  1117. unmounted if no accesses are made to it.  The packet layout is as follows:
  1118.  
  1119.     Offset  Size    Type        Description
  1120.  
  1121.        0      2     WORD        Magic value 'C0'
  1122.        2      2     WORD        Packet type 6, PACKET_SET_TIMEOUT
  1123.        4      2     WORD        Timeout value in minutes before unmount
  1124.                                 takes place
  1125.  
  1126. Specifying a value of 0 as the timeout value will disable the timed unmount
  1127. feature in the driver.
  1128.  
  1129. The timed unmount is handled under DOS by hooking the int 1Ch timer interrupt.
  1130. The interrupt handler which performs this task is installed either when the
  1131. driver is loaded (if a timeout value is specified at this time), or when
  1132. mountsfs is run and a timeout value is specified (which transmits a timed
  1133. unmount control packet to the driver).  Under Windows, the same task is
  1134. performed by the Windows SFS driver sending Windows Clock Tick packets (see
  1135. below) to the driver.
  1136.  
  1137. The timed unmount handler decrements a timer and unmounts the volume if it
  1138. expires.  The timer is reset every time a media check packet is received by the
  1139. driver, which allows normal DOS and Windows accesses to be detected but doesn't
  1140. cause false triggering due to device driver control functions.  Subsequent
  1141. timed unmount control packets can be sent to the driver to change the actual
  1142. timeout value for a volume.  Sending a value of 0 will disable the timer and,
  1143. if no more volumes have timers set, deinstall the timer interrupt handler if
  1144. one is installed.
  1145.  
  1146.  
  1147. Packet 7 - Windows Clock Tick
  1148.  
  1149. This packet differs from all the others in that it transmits no information to
  1150. the driver other than that conveyed by it's presence.  It is sent by the
  1151. Windows SFS driver every 10 seconds and is used to allow the driver to handle
  1152. timed unmounts and perform smart card processing under Windows, which
  1153. virtualizes the timer interrupt and locks out the driver, in effect replacing
  1154. the normal timer interrupt.  In addition, it allows the driver to report back
  1155. to the SFS Windows driver the current status of any mounted volumes, rather
  1156. than providing the audible feedback it does under DOS.  In order to do this,
  1157. the driver performs the rather unusual step of writing into two reserved fields
  1158. in the received data packet, which eliminates the need for a seperate, slow
  1159. IOCTL read every 10 seconds.  The packet layout is as follows:
  1160.  
  1161.     Offset  Size    Type        Description
  1162.  
  1163.        0      2     WORD        Magic value 'C0'
  1164.        2      2     WORD        Packet type 7, PACKET_WIN_CLOCKTICK
  1165.        4      2     WORD        Returned count of unmounted volumes.  0 = none
  1166.                                 unmounted, -1 = all volumes unmounted due to
  1167.                                 smart card removal, anything else = count of
  1168.                                 unmounted volume.
  1169.        6      2     WORD        Returned current quick-unmount hotkey setting.
  1170.  
  1171. The returned count of unmounted volumes can be used to display a dialog box
  1172. indicating to the user that an unmount has occurred.  The returned
  1173. quick-unmount hotkey setting is used by the Windows SFS driver to update its
  1174. internal status of the hotkey setting is changed from DOS.
  1175.  
  1176.  
  1177. Packet 8 - Smart Card Control Information
  1178.  
  1179. This packet consists of a number of sub-packet types which are used to control
  1180. the handling of smart cards by the driver.  The packet layout is as follows:
  1181.  
  1182.     Offset  Size    Type        Description
  1183.  
  1184.        0      2     WORD        Magic value 'C0'
  1185.        2      2     WORD        Packet type 8, PACKET_SET_CARDINFO
  1186.        4      2     WORD        Sub-packet type (see below).
  1187.        6      2     WORD        Card type
  1188.        8     ??     BYTE[]      Card-specific information
  1189.  
  1190. The packet sub-types are as follows:
  1191.  
  1192.     Name                    Value       Information type
  1193.  
  1194.     CARD_PKT_SUSPEND          0         Suspend smart card handling
  1195.     CARD_PKT_RESUME           1         Resume smart card handling
  1196.     CARD_PKT_CLEAR_THIS       2         Clear card handling for the current
  1197.                                         volume
  1198.     CARD_PKT_RO_THIS          3         Enable card handling, make current
  1199.                                         volume readonly if card removed
  1200.     CARD_PKT_UMT_THIS         4         Enable card handling, unmount current
  1201.                                         volume if card removed
  1202.     CARD_PKT_CLEAR_ALL        5         Clear card handling for all volumes
  1203.     CARD_PKT_UMT_ALL          6         Enable card handling, unmount all
  1204.                                         volumes if card removed
  1205.  
  1206. Use of the CARD_PKT_SUSPEND and CARD_PKT_RESUME packet subtypes allow the the
  1207. smart card reader to be used without the need to unmount and re-mount volumes
  1208. when the card is removed.  For example, to initialise a new card, the suspend
  1209. packet is sent to the driver, the current card is removed and a blank card
  1210. inserted, the blank card is initialised, the old card is reinserted, and the
  1211. resume packet is sent.  Unlike all other packets types, the driver will not
  1212. update the reader LED when these packets are received, leaving it under the
  1213. control of the calling application.
  1214.  
  1215. The mount control packets CARD_PKT_CLEAR_THIS, CARD_PKT_RO_THIS,
  1216. CARD_PKT_UMT_THIS, CARD_PKT_CLEAR_ALL, and CARD_PKT_UMT_ALL control the
  1217. drivers' handling of the currently inserted card.  The first three packet
  1218. subtypes specify how a card removal is to control the operation of the
  1219. currently addressed volume, the last two packet subtypes specify how a card
  1220. removal is to control the operation of all volumes.  It is possible to
  1221. individually control the handling of volumes, so that a card removal could
  1222. unmount one volume, make a second volume readonly, and have no effect on a
  1223. third volume.  Volumes do not need to be mounted using the smart card in order
  1224. for them to be affected by a smart card removal.  Sending any of these packet
  1225. types will cause the driver to update the status of the card reader LED.
  1226.  
  1227.  
  1228. Controlling the Driver
  1229.  
  1230. The SFS driver is initialized by sending it a series of control packets giving
  1231. the disk information, the keying information, the drive number and logical
  1232. volume offset to access, the read/write status, and finally the mount command.
  1233. The sequence of operations for mounting a volume is as follows:
  1234.  
  1235.     driveNumber <- find SFS drive number as outlined above;
  1236.     ioctlWrite( driveNumber, PACKET_SET_DISKINFO, \
  1237.                 disk information - packet type 0 );
  1238.     ioctlWrite( driveNumber, PACKET_SET_KEYINFO, \
  1239.                 keying information - packet type 1 );
  1240.     ioctlWrite( driveNumber, PACKET_SET_READONLY, \
  1241.                 read-only status - packet type 2 );
  1242.     ioctlWrite( driveNumber, PACKET_SET_DRIVENO, \
  1243.                 drive to mount and vol.offs - packet type 3 );
  1244.     ioctlWrite( driveNumber, PACKET_SET_MOUNTSTATUS, \
  1245.                 mount status TRUE - packet type 4 );
  1246.  
  1247. To mount a new volume on the same drive:
  1248.  
  1249.     driveNumber <- find SFS drive number as outlined above;
  1250.     ioctlWrite( driveNumber, PACKET_SET_KEYINFO, \
  1251.                 keying information - packet type 1 );
  1252.     ioctlWrite( driveNumber, PACKET_SET_MOUNTSTATUS, \
  1253.                 mount status TRUE - packet type 4 );
  1254.  
  1255. To unmount a volume, erasing the keying information held by the device driver:
  1256.  
  1257.     driveNumber <- find SFS drive number as outlined above;
  1258.     ioctlWrite( driverNumber, PACKET_SET_MOUNTSTATUS, \
  1259.                 mount status FALSE - packet type 4 );
  1260.